	//평균스코어
	function clsMyScoreState_Avg(){
		this.listData = null;
		this._HTMLDom = null;
		this._init();	
	}
	
	clsMyScoreState_Avg.prototype = {
		_init: function(){
			var $layer = $("section#my_score_state>section div.my_score table tbody tr:eq(0) td");
			this._HTMLDom = {
				"$layer": $layer				
			};
		}	
		, setData: function(thisData){
			this.listData = thisData
			this.display();
		}
		, display: function(thisData){						
			var $layer = this._HTMLDom["$layer"];
			
			 //$layer.html(this.listData["스코어"]);
		}
	}
	//베스트스코어
	function clsMyScoreState_Best(){
		this.listData = null;
		this._HTMLDom = null;
		this._init();	
	}
	
	clsMyScoreState_Best.prototype = {
		_init: function(){
			var $layer = $("section#my_score_state>section div.my_score table tbody tr:eq(1) td");
			this._HTMLDom = {
				"$layer": $layer				
			};
		}	
		, setData: function(thisData){
			this.listData = thisData
			this.display();
		}
		, display: function(thisData){						
			var $layer = this._HTMLDom["$layer"];
			
			$layer.html(this.listData["골프장명"] + "&nbsp"+ this.listData["코스명"] +"<em>"+ this.listData["스코어"] +"</em>");
		}
	}
	
	//최대스코어
	function clsMyScoreState_Worst(){
		this.listData = null;
		this._HTMLDom = null;
		this._init();	
	}
	
	clsMyScoreState_Worst.prototype = {
		_init: function(){
			var $layer = $("section#my_score_state>section div.my_score table tbody tr:eq(2) td");
			this._HTMLDom = {
				"$layer": $layer
			};
		}	
		, setData: clsMyScoreState_Best.prototype.setData
		, display: clsMyScoreState_Best.prototype.display
		
	}
	
	  
	
	//스코어통계
	function clsMyScoreState(){
		this.listData = null;
		this._HTMLDom = null;
		this._init();
	}	
	
	clsMyScoreState.prototype = {
		_init: function(){
			var $layer = $("section#my_score_state>section");
			this._HTMLDom = {
				"$layer": $layer				
			};
		}	
		, setData: function(thisData){
			this.listData = thisData
			this.display();
		}
		, display: function(thisData){						
			var $stat = this._HTMLDom["$layer"].find("div.my_score_state table tbody");
			var $avg = this._HTMLDom["$layer"].find("div.my_score_state table tfoot");
			var thisClass = this;
			
			for(var n=0;n<this.listData.length;++n){
				var d = thisClass.listData[n];
				var par = n+3;
				
				d = d || {};
				
				d["더블보기"] = _util.nvl(d["더블보기"], 0);
				d["보기"] = _util.nvl(d["보기"], 0);
				d["파"] = _util.nvl(d["파"], 0);
				d["버디"] = _util.nvl(d["버디"], 0);
				d["이글"] = _util.nvl(d["이글"], 0);
				d["홀인원"] = _util.nvl(d["홀인원"], 0);
				
				var total = d["더블보기"]*(par+2) + d["보기"]*(par+1) + d["파"]*par + d["버디"]*(par-1) + d["이글"]*(par-1) + d["홀인원"];
				var per = d["더블보기"] + d["보기"] + d["파"] + d["버디"]+ d["이글"] + d["홀인원"];
				
				per = per || 1;
				
				$stat.find("tr:eq(0) td").eq(n+1).html(d["더블보기"] +"<em>"+ _util.roundEx((d["더블보기"]*100/per), -1) +"%</em>");
				$stat.find("tr:eq(1) td").eq(n+1).html(d["보기"] +"<em>"+ _util.roundEx((d["보기"]*100/per), -1) +"%</em>");
				$stat.find("tr:eq(2) td").eq(n+1).html(d["파"] +"<em>"+ _util.roundEx((d["파"]*100/per), -1) +"%</em>");
				$stat.find("tr:eq(3) td").eq(n+1).html(d["버디"] +"<em>"+ _util.roundEx((d["버디"]*100/per), -1) +"%</em>");
				if(n==0){
					$stat.find("tr:eq(4) td").eq(n+1).html("-<em>-</em>");
				}else {
					$stat.find("tr:eq(4) td").eq(n+1).html(d["이글"] +"<em>"+ _util.roundEx((d["이글"]*100/per), -1) +"%</em>");
				}
				$stat.find("tr:eq(5) td").eq(n+1).html(d["홀인원"] +"<em>"+ _util.roundEx((d["홀인원"]*100/per), -1) +"%</em>");
				$avg.find("tr td").eq(n+1).html(_util.roundEx(total/per, -1));				
			}
		}
	}
	
	//데이터연동		
	function clsComm_MyScoreState(){
		this.avgScore = null;
		this.bestScore = null;
		this.worstScore = null;
		this.scoreState = null;		
		this.scoreStateRequest = null;
		
		this._init();
	}	
	clsComm_MyScoreState.prototype = {
		_init: function(){
			this.scoreStateRequest = {
				"아이디": "golfin"	
				, "페이지": null
			}
		}
//------------------------ 평균스코어조회------------------------//	
		, getScoreStateAvg: function(){
			var thisClass = this;
			var objJson = new MJson();
        	var cm = new ConnectionManager();
			
			objJson.putClient("userid", "golfin3");
			objJson.putPub("sid", "US001");
        	objJson.putPub("servicename", "getMyAverageScore");        	

        	cm.requestGet(objJson.getJsonString(), function(ret){
				
				var items = ret["msp"]["contents"]["items"];
				
				if(items) thisClass.avgScore = {
					"스코어": items
				}
			
				$(thisClass).trigger("evtFinishScoreStateAvg");
			}, function($err) {
				alert($err);
			});
		}
		, getScoreStateAvgData: function(){
			return this.avgScore;	
		}
//------------------------ 평균스코어조회------------------------//
//------------------------ 베스트스코어조회------------------------//		
		, getScoreStateBest: function(){
			var thisClass = this;
			var objJson = new MJson();
        	var cm = new ConnectionManager();
			
			objJson.putClient("userid", "golfin3");
        	objJson.putPub("sid", "US001");
        	objJson.putPub("servicename", "getMyWorstScore");
        	
        	cm.requestGet(objJson.getJsonString(), function(ret){
				
				var items = ret["msp"]["contents"]["items"];
				
				if(items){
					thisClass.bestScore = {
						"골프장명": items["golfclubName"]
						, "코스명": items["courseInfoName"]
						, "스코어": items["score"]
					}
				}
			
				$(thisClass).trigger("evtFinishScoreStateBest");
			}, function($err) {
				alert($err);
			});
		}
		, getScoreStateBestData: function(){
			return this.bestScore;
		}
//------------------------ 베스트스코어조회------------------------//			
//------------------------ 최대스코어조회------------------------//	
		, getScoreStateWorst: function(){
			var thisClass = this;
			var objJson = new MJson();
        	var cm = new ConnectionManager();
			
			objJson.putClient("userid", "golfin3");
        	objJson.putPub("sid", "US001");
        	objJson.putPub("servicename", "getMyBestScore");
        	
        	cm.requestGet(objJson.getJsonString(), function(ret){
				
				var items = ret["msp"]["contents"]["items"];
				
				if(items){
					thisClass.worstScore = {
						"골프장명": items["golfclubName"]
						, "코스명": items["courseInfoName"]
						, "스코어": items["score"]
					}
				}
			
				$(thisClass).trigger("evtFinishScoreStateWorst");
			}, function($err) {
				alert($err);
			});
		}	
		, getScoreStateWorstData: function(){
			return this.worstScore;
		}
//------------------------ 최대스코어조회------------------------//			
//------------------------ 스코어통계조회------------------------//	
		, getScoreState: function(){
			var thisClass = this;
			
			var objJson = new MJson();
        	var cm = new ConnectionManager();
			
			objJson.putClient("userid", "golfin3");
			objJson.putPub("sid", "US001");
        	objJson.putPub("servicename", "getMyScoreStats");
        	

        	cm.requestGet(objJson.getJsonString(), function(ret){
				
				var items = ret["msp"]["contents"]["items"];
				
				if(items){
					thisClass.scoreState = [];
					var obj = items;
					for(var i=3;i<6;i++){
						thisClass.scoreState.push({
							"더블보기": _util.nvl(obj["doubleBogey" + i], 0)
							, "보기": _util.nvl(obj["bogey" + i], 0)
							, "파": _util.nvl(obj["par" + i], 0)
							, "버디": _util.nvl(obj["birdie" + i], 0)
							, "이글": _util.nvl(obj["eagle" + i], 0)
							, "홀인원": _util.nvl(obj["holeInOne" + i], 0)
						});
					}
				}
			
				$(thisClass).trigger("evtFinishScoreState");
			}, function($err) {
				alert($err);
			});
		}
		, getScoreStateData: function(){
			return this.scoreState;	
		}
		, setScoreStateRequest: function(key,val){
			this.scoreStateRequest[key]=val;
		}
		, getScoreStateRequest: function(key){
			return this.scoreStateRequest[key];
		}
//------------------------ 스코어통계조회------------------------//			
	}
	
	//컨트롤파일
	function MyScoreState(){	
		this.objComm = null;	
		
		this.objMyScoreState = null;
		this.objMyScoreState_Avg = null;
		this.objMyScoreState_Best = null;
		this.objMyScoreState_Worst = null;
	};
	
	MyScoreState.prototype = {
	    onPageShow : function() {
	    	/*사용자 로그인체크
	    	if(!common.userCheck()){
	    		alert("로그인 후 사용하시기 바랍니다.");
	    		return;
	    	}
	    	*/	      
	    	
	    	this._init();
	    	this.spinStart();
	    }
	    , _init: function(){	    	
	    	$("a").attr("href", "").attr("data-rel", "");	    	
	    	
			this.objComm = new clsComm_MyScoreState();
	      	this.objMyScoreState = new clsMyScoreState();
	      	this.objMyScoreState_Avg = new clsMyScoreState_Avg();
			this.objMyScoreState_Best = new clsMyScoreState_Best();
			this.objMyScoreState_Worst = new clsMyScoreState_Worst();
			
			this.getParam();
			
			this._role();
	      	
	      	this._bind();
	      	this._eventFinish();
	    }
	    , _start: function(){	       
	      	//스코어통계 조회
	      	this.spinStart();
	      	this.objComm.setScoreStateRequest("페이지",1);
	      	this.objComm.getScoreState();
	      	this.objComm.getScoreStateAvg();
	      	this.objComm.getScoreStateBest();
	      	this.objComm.getScoreStateWorst();
	    }
	    , _eventFinish: function(){
	    	var thisClass = this;
	    	
	    	//스코어상태조회 완료 이벤트
		 	$(this.objComm).bind("evtFinishScoreState", function(event){
		 		var thisData = thisClass.objComm.getScoreStateData();
		 		thisClass.objMyScoreState.setData(thisData);
		 		thisClass.spinEnd();
		 	});
		 	
		 	//평균스코어조회 완료 이벤트
		 	$(this.objComm).bind("evtFinishScoreStateAvg",function(event){
		 		var thisData = thisClass.objComm.getScoreStateAvgData();
		 		thisClass.objMyScoreState_Avg.setData(thisData);
		 		thisClass.spinEnd();
		 	});
		 	
		 	//베스트스코어조회 완료 이벤트
		 	$(this.objComm).bind("evtFinishScoreStateBest",function(event){
		 		var thisData = thisClass.objComm.getScoreStateBestData();
		 		thisClass.objMyScoreState_Best.setData(thisData);
		 		thisClass.spinEnd();
		 	});
		 	
		 	//최대스코어조회 완료 이벤트
		 	$(this.objComm).bind("evtFinishScoreStateWorst",function(event){
		 		var thisData = thisClass.objComm.getScoreStateWorstData();
		 		thisClass.objMyScoreState_Worst.setData(thisData);
		 		thisClass.spinEnd();
		 	});
	    }
		 , _bind: function(){
		 	var thisClass = this;		 	
		 	
		 	//전체스코어
		 	$("section#my_score_state>footer ul li:eq(0) a").click(function(event){
		 		event.preventDefault();	
		 		$.mobile.changePage("my_score.html","slide",true);	
		 	});
		 	
		 	//스코어등록
		 	$("section#my_score_state>footer ul li:eq(1) a").click(function(event){
		 		event.preventDefault();	
		 		_gf.MYPAGE_DATA  = {
		 			"예약코드": null	
		 		}
		 		$.mobile.changePage("my_score_record.html","slide",true);	
		 	});
		 	
		 	//나의스코어통계
		 	$("section#my_score_state>footer ul li:eq(2) a").click(function(event){
		 		event.preventDefault();	
		 		$.mobile.changePage("my_score_state.html","slide",true);	
		 	});
		 	
		 	//메뉴
		 	$("section#my_score_state nav ul li a:eq(0)").click(function(event){
		 		event.preventDefault();
		 		$.mobile.changePage( "../inc/navi.html","slide",true);	
		 	});
		 	
		 	//알림
		 	$("section#my_score_state nav ul li:eq(1)").click(function(event){
		 		event.preventDefault();
		 		$.mobile.changePage("../inc/info_booking.html","slide",true);	
		 	});
		 }
		 , getParam: function(){
		 	
		 }
	     , _role: function(){
	    		if(!_util.getLogin("로그인")){
	    			//alert("로그인 후 이용하실 수 있습니다.");		    			
	    			this.goNavi();		
	    			return;
	    		}else {
    				this._start();	    		
    			}
	   }
		, goNavi: function(){			
			$.mobile.changePage("../inc/navi.html","slide",true);
		}
		, goNavi: function(){
    		//$.mobile.changePage("../inc/navi.html","slide",true);
		}
		 , spinStart: function(){		
			$.mobile.showPageLoadingMsg();			
		 }
		 , spinEnd: function(){			
			$.mobile.hidePageLoadingMsg();				
		 }
	}